#include "head_s.h"       //头文件要该嗷

//登录
int login(user_t* status,const portocol_t* portocol,int net_fd){
    char buf[100] = {0};
    //char password[100] = {0};
    //recv(net_fd,name,sizeof(name),MSG_WAITALL);
    //拼接路径
    printf("login: base_path = %s, user_name = %s\n", status->base_path, status->user_name);
    sprintf(buf,"%s%s",status->base_path,status->user_name);
    printf("%s\n", buf);
    //比较是否已有这个用户，是否可以登录
    DIR *dir = opendir(buf);

    if(dir){
        //用户存在，等待输入密码
        send(net_fd,"true",4,0);
        //recv(net_fd,password,sizeof(password),0);

        //比较密码
    }else{
        //用户不存在，给客户端返回信息提示
        send(net_fd,"false",5,0);
    }
}


//注册
int regist(user_t* status,const portocol_t* portocol,int net_fd){
    char buf[100] = {0};
    printf("123123123\n");
    //recv(net_fd,name,sizeof(name),MSG_WAITALL);

    //拼接路径
    sprintf(buf,"%s%s",status->base_path,status->user_name);
    printf("%s\n", buf);
    //比较是否已有这个用户，是否可以登录
    DIR *dir = opendir(buf);
    
    if(dir){
        //用户存在，等待输入密码
        send(net_fd,"false",5,0);
        //recv(net_fd,password,sizeof(password),0);

        //比较密码
    }else{
        //用户不存在，给客户端返回信息提示
        printf("%s\n", buf);
        int ret = mkdir(buf, 0775);
        printf("%d\n", ret);
        send(net_fd,"true",4,0);
    }

}
